var e, t, n = require("../../../../@babel/runtime/helpers/toConsumableArray"), i = require("../../../../@babel/runtime/helpers/objectSpread2"), s = require("../../../../common/vendor.js"), u = require("../../../uv-ui-tools/libs/mixin/mpMixin.js"), o = require("../../../uv-ui-tools/libs/mixin/mixin.js");

require("../../../uv-ui-tools/libs/function/index.js"), require("../../../uv-ui-tools/libs/function/test.js"), 
require("../../../uv-ui-tools/libs/function/digit.js"), require("../../../uv-ui-tools/libs/util/route.js"), 
require("../../../uv-ui-tools/libs/function/debounce.js"), require("../../../uv-ui-tools/libs/function/throttle.js");

var r = {
    name: "uv-skeletons",
    mixins: [ u.mpMixin, o.mixin ],
    props: i({
        loading: {
            type: Boolean,
            default: !0
        },
        skeleton: {
            type: Array,
            default: function() {
                return [];
            }
        },
        animate: {
            type: Boolean,
            default: !0
        },
        round: {
            type: Boolean,
            default: !1
        }
    }, null == (t = null == (e = s.index.$uv) ? void 0 : e.props) ? void 0 : t.skeleton),
    data: function() {
        return {
            elements: [],
            opacity: .5,
            duration: 600
        };
    },
    computed: {
        animateClass: function() {
            return this.animate ? "uv-skeleton--animation" : "uv-skeleton--static";
        },
        roundClass: function() {
            return this.round ? "uv-skeleton--round" : "uv-skeleton--radius";
        },
        style: function(e) {
            var t = this;
            return function(e) {
                return t.$uv.deepMerge({}, t.$uv.addStyle(e.style));
            };
        }
    },
    created: function() {
        this.init();
    },
    methods: {
        init: function() {
            var e = this, t = [];
            if (!this.$uv.test.array(this.skeleton)) return this.$uv.error("skeleton参数必须为数组形式，参考文档示例：");
            this.skeleton.forEach(function(n) {
                var i = e.getElCounts(n);
                t = t.concat(i);
            }), this.elements = n(t);
        },
        getElCounts: function(e) {
            var t = [], n = [];
            if (this.$uv.test.number(e)) return t.push({
                type: "gap",
                height: e
            }), t;
            for (var i = e.type ? e.type : "line", s = e.num ? e.num : 1, u = e.style ? e.style : {}, o = this.$uv.test.array(u), r = e.gap ? e.gap : "20rpx", a = e.children ? e.children : [], l = 0; l < a.length; l++) n[l] = {
                clas: a[l].type.indexOf("avatar") > -1 || a[l].type.indexOf("custom") > -1 ? "" : "uv-skeleton__group__sub",
                elements: this.getElCounts(a[l])
            };
            for (var c = 0; c < s; c++) r && c < s && c > 0 && t.push({
                type: "gap",
                height: r
            }), t.push({
                clas: "uv-skeleton__".concat(i),
                type: i,
                style: o ? u[c] : u,
                gap: r,
                children: n
            });
            return t;
        },
        createAnimation: function() {
            var e = this, t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 1;
            if (this.loading && this.animate) {
                var n = 0, i = this.$refs.skeleton;
                i.forEach(function(s) {
                    animation.transition(s, {
                        styles: {
                            opacity: t
                        },
                        duration: e.duration
                    }, function() {
                        ++n >= i.length && setTimeout(function() {
                            e.createAnimation(t < 1 ? 1 : e.opacity);
                        }, 200);
                    });
                });
            }
        }
    }
}, a = s._export_sfc(r, [ [ "render", function(e, t, n, i, u, o) {
    return s.e({
        a: n.loading
    }, n.loading ? {
        b: s.f(u.elements, function(t, n, i) {
            return s.e({
                a: "flex" == t.type
            }, "flex" == t.type ? {
                b: s.f(t.children, function(t, n, i) {
                    return {
                        a: s.f(t.elements, function(t, n, i) {
                            return s.e({
                                a: "gap" == t.type
                            }, "gap" == t.type ? {
                                b: e.$uv.addUnit(t.height, "rpx")
                            } : {
                                c: s.n(t.clas),
                                d: s.n(o.roundClass),
                                e: s.n(o.animateClass),
                                f: s.s(o.style(t))
                            }, {
                                g: n
                            });
                        }),
                        b: s.n(t.clas),
                        c: s.s(o.style(t)),
                        d: n
                    };
                }),
                c: s.s(o.style(t))
            } : "custom" == t.type ? {
                e: s.n(t.clas),
                f: s.n(o.animateClass),
                g: s.s(o.style(t))
            } : "gap" == t.type ? {
                i: e.$uv.addUnit(t.height, "rpx")
            } : {
                j: s.n(t.clas),
                k: s.n(o.roundClass),
                l: s.n(o.animateClass),
                m: s.s(o.style(t))
            }, {
                d: "custom" == t.type,
                h: "gap" == t.type,
                n: n
            });
        })
    } : {});
} ], [ "__scopeId", "data-v-cf4a5463" ] ]);

wx.createComponent(a);